package com.block.test.service.impl;

import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.block.common.bean.SessionBean;
import com.block.common.constant.AppRspCodeConstant;
import com.block.common.model.vo.ResultInfoVO;
import com.block.common.vo.ResponseVo;
import com.block.test.service.IValidateService;
import org.springframework.stereotype.Service;

@Service
public class UpdateAuthInfoValidateService extends IValidateService {

    @Override
    public ResponseVo validate(Object object, JSONObject jsonObject, SessionBean sessionBean) {

        String idcard = jsonObject.getString("idcard");
        String realname = jsonObject.getString("realname");
        if (!IdcardUtil.isValidCard(idcard)){
            return new ResponseVo(AppRspCodeConstant.PARAM_ERROR, "请输入合法身份证");
        }
        if (StrUtil.length(realname) < 2){
            return new ResponseVo(AppRspCodeConstant.PARAM_ERROR, "请输入合法姓名");
        }
        return null;
    }

    @Override
    public ResultInfoVO validate2(Object object, JSONObject jsonObject) {
        return null;
    }
}
